<script setup lang="ts">
import useCategory from "@/store/category.ts";
import {onMounted} from "vue";
// 当添加属性时，禁用选择框
defineProps(["scene"]);
const categoryStore = useCategory();
const getC1 = () => {
  categoryStore.getCategory1();
}
onMounted(()=>{
  getC1();
})

const handleC1 = ()=>{
  categoryStore.c2ID = null;
  categoryStore.c3ID = null;
  categoryStore.getC2();
}
const handleC2 = ()=>{
  categoryStore.c3ID = null;
  categoryStore.getC3();
}
</script>

<template>
  <el-card>
    <el-form inline>
      <el-form-item label="一级分类">
        <el-select
            :disabled="!!scene"
            v-model="categoryStore.c1ID"
            @change="handleC1"
            clearable>
          <el-option
              v-for="item in categoryStore.c1Arr"
              :key="item.id"
              :label="item.name"
              :value="item.id" />
        </el-select>
      </el-form-item>

      <el-form-item label="二级分类">
        <el-select
            :disabled="!!scene"
            v-model="categoryStore.c2ID"
            @change="handleC2"
            clearable>
          <el-option
              v-for="item in categoryStore.c2Arr"
              :key="item.id"
              :label="item.name"
              :value="item.id" />
        </el-select>
      </el-form-item>

      <el-form-item label="三级分类">
        <el-select
            :disabled="!!scene"
            v-model="categoryStore.c3ID"
            clearable>
          <el-option
              v-for="item in categoryStore.c3Arr"
              :key="item.id"
              :label="item.name"
              :value="item.id" />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<style scoped lang="scss">

</style>